package com.clean.cleantotal.compores.battery

import android.os.Bundle
import androidx.core.view.isVisible
import com.clean.cleantotal.R
import com.clean.cleantotal.base.BaseActivity
import com.clean.cleantotal.bean.DataUtils
import com.clean.cleantotal.bean.FunType
import com.clean.cleantotal.bean.InfoBean
import com.clean.cleantotal.databinding.ActivityBatteryBinding
import com.clean.cleantotal.compores.result.ResultActivity
import com.clean.cleantotal.utils.MyDeviceUtils
import com.clean.cleantotal.utils.Utils
import com.drake.brv.utils.linear
import com.drake.brv.utils.setup

class BatteryActivity : BaseActivity<ActivityBatteryBinding>() {
    override val viewBinding: ActivityBatteryBinding
        get() = ActivityBatteryBinding.inflate(layoutInflater)

    override fun initView() {
        mBinding.back.setOnClickListener { onBackPressed() }
        Utils.showScanDialog(this, FunType.BATTERY, mBinding.loadingLayout.scanLayout, {
            animal = it
        }) {

        }
        mBinding.recyclerView.linear().setup {
            addType<InfoBean> { R.layout.item_battery_layout }
        }.models = DataUtils.getBatteryList(intent, this) {
            mBinding.includedLayout.yellowYuan.isVisible = true
            mBinding.includedLayout.tvSize.text = it
            mBinding.includedLayout.tvUnit.text = "%"
            mBinding.includedLayout.ivFinish.isVisible = false
            mBinding.includedLayout.tvTitle.text = "${MyDeviceUtils.getBatteryTotalPower(this)}mAh"
            mBinding.includedLayout.tvContent.text = "Estimated usable time"
        }
        animal?.duration = 3000

        mBinding.okLayout.setOnClickListener {
            openActivity(ResultActivity::class.java, Bundle().apply {
                putSerializable("funType", FunType.BATTERY)
                finish()
            })
        }
    }

}